// JavaScript Document

function getParameter(name) 
{
	var url = window.location.href;
	var tempUrl = window.location.href.toLowerCase();
	var paramsStart = url.indexOf("?");
	name = name.toLowerCase();    
	
	if(paramsStart != -1)
	{
       var tempParamString = tempUrl.substr(paramsStart + 1);	   
	   var paramString = url.substr(paramsStart + 1);       
	   var tokenStart = tempParamString.indexOf(name);	   
	   if(tokenStart != -1)
	   {          
		  paramToEnd = paramString.substr(tokenStart + name.length + 1);
		  var delimiterPos = paramToEnd.indexOf("&");          
		  if(delimiterPos == -1)
		  {
             return paramToEnd;			 
          }
          else 
		  {             
			 return paramToEnd.substr(0, delimiterPos);
          }
       }
	   else
	   {
			return "";
	   }
    }
	else
	{
		return "";
	}
}
function bookmarkPage(tempURL,tempPageName)
{
	var urlAddress = tempURL;//"http://info.vmware.com/content/4689_ADC_WP_TY";
	var pageName = tempPageName;//"VMware";
	if (window.external)
	{
		window.external.AddFavorite(urlAddress,pageName)
	}
	else
	{ 
		alert("Sorry! Your browser doesn't support this function.");
	}
}
function checkContactRegistered(tempContactGroupID)
{
	var strContactGroupGUID = tempContactGroupID;
	var finalDestination = "";
	var redirectType = getParameter('redirectType');
	var redirectLocation = getParameter('redirectLocation');
	var elq = getParameter('elq');
	var src = getParameter('src');
	var ossrc = getParameter('ossrc');
	var qsParameterString = "?src=" + src + "&ossrc=" + ossrc+ "&elq=" + elq; 
	var anchorString = "";
	if(redirectType == "pdf" || redirectType == "zips")
	{
		finalDestination = "http://www.vmware.com/files/elqNow/elqRedir.htm?ref=http://download3.vmware.com/elq/" + redirectType +"/" + redirectLocation + qsParameterString;
	}
	else
	{
		if(redirectLocation.indexOf("%3F") != -1)
		{
			redirectLocation = redirectLocation.replace(/%3F/g,"?");
			qsParameterString = qsParameterString.replace("?","&");
		}
		if(redirectLocation.indexOf("%23") != -1)
		{
			startLocation = redirectLocation.indexOf("%23");
			endLocation = redirectLocation.length;
			anchorString = redirectLocation.substring(startLocation,endLocation);			
			redirectLocation = redirectLocation.replace(anchorString,"");
			anchorString = anchorString.replace("%23","#");
		}
		redirectLocation = redirectLocation.replace(/%26/g,"&");
		finalDestination = redirectType + redirectLocation + qsParameterString + anchorString;	
	}	
	if (this.GetElqGroupMembershipStatus)
	{
		if(GetElqGroupMembershipStatus(strContactGroupGUID))
		{
			window.location = finalDestination;			
		}
		else
		{ 
			document.getElementById("bodyContent").style.visibility = "visible"
			document.getElementById("elqDefaultTargetURL").value = finalDestination;	
		}
	}
	else
	{ 
		document.getElementById("bodyContent").style.visibility = "visible"
		document.getElementById("elqDefaultTargetURL").value = finalDestination;	
	}
}
function dlContactRegistered(tempContactGroupID, tempFinalDestination)
{
	var strContactGroupGUID = tempContactGroupID;
	var finalDestination = tempFinalDestination;
	var redirectType = getParameter('redirectType');
	var redirectLocation = getParameter('redirectLocation');
	var elq = getParameter('elq');
	var src = getParameter('src');
	var ossrc = getParameter('ossrc');
	var qsParameterString = "?src=" + src + "&ossrc=" + ossrc+ "&elq=" + elq; 
	var anchorString = "";
	if(redirectType == "pdf" || redirectType == "zips")
	{
		finalDestination = "http://www.vmware.com/files/elqNow/elqRedir.htm?ref=http://download3.vmware.com/elq/" + redirectType +"/" + redirectLocation + qsParameterString;
	}
	else
	{
		if(redirectLocation.indexOf("%3F") != -1)
		{
			redirectLocation = redirectLocation.replace(/%3F/g,"?");
			qsParameterString = qsParameterString.replace("?","&");
		}
		if(redirectLocation.indexOf("%23") != -1)
		{
			startLocation = redirectLocation.indexOf("%23");
			endLocation = redirectLocation.length;
			anchorString = redirectLocation.substring(startLocation,endLocation);			
			redirectLocation = redirectLocation.replace(anchorString,"");
			anchorString = anchorString.replace("%23","#");
		}
		redirectLocation = redirectLocation.replace(/%26/g,"&");
		finalDestination = redirectType + redirectLocation + qsParameterString + anchorString;	
	}	
	if (this.GetElqGroupMembershipStatus)
	{
		if(GetElqGroupMembershipStatus(strContactGroupGUID))
		{
			window.location = finalDestination;			
		}
		else
		{ 
			document.getElementById("bodyContent").style.visibility = "visible"
			document.getElementById("elqDefaultTargetURL").value = finalDestination;	
		}
	}
	else
	{ 
		document.getElementById("bodyContent").style.visibility = "visible"
		document.getElementById("elqDefaultTargetURL").value = finalDestination;	
	}
}